﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SingletonPattern
{
    public class SingleObject
    {
        /// <summary>
        /// 创建一个实例
        /// </summary>
        private static SingleObject instance = new SingleObject();

        /// <summary>
        /// 私有构造方法
        /// </summary>
        private SingleObject() { }

        public static SingleObject GetInstance()
        {
            return instance;
        }

        public void ShowMessage()
        {
            Console.WriteLine("Hello World!");
        }
    }
}
